module.exports = {
  env: {
    QN_URL: process.env.QN_URL || 'https://qn.yaavi.me/'
  },
  build: {
    analyze: {
      analyzerMode: 'static'
    },
    babel: {
      presets: ['es2015', 'stage-0'],
      plugins: [
        'transform-async-to-generator',
        'transform-runtime'
      ],
      comments: true
    },
    extend (config, { isClient }) {
      // 为 客户端打包 进行扩展配置
      if (isClient) {
        // config.devtool = 'eval-source-map'
      }
      if (process.env.NODE_ENV == 'production') {
        // console.log('production')
      }
    },
    filenames: {
      // vendor: 'vendor.[hash].js',
      // app: 'app.[chunkhash].js'
    },
    styleResources: {
      stylus: './assets/css/var.styl',
      options: {}
    },
    postcss: [
      // require('postcss-nested')(),
      // require('postcss-responsive-type')(),
      // require('postcss-hexrgba')(),
      require('autoprefixer')({
        browsers: [
          "> 1%",
          "iOS >= 7",
          "Android > 4",
          "Firefox >= 10",
          "ie >= 8"
        ]
      })
    ],
    publicPath: '/_nuxt/', // 建议上传到cdn 'https://cdn.nuxtjs.org'
    vendor: [
      // 'better-scroll',
      'particles.js',
      'vue-awesome-swiper'
    ],
    maxChunkSize: 350000
  },
  head: {
    title: '一个前端菜鸟的博客',
    titleTemplate: '%s | Yaavi.me',
    htmlAttrs: {
      // xmlns: 'http://www.w3.org/1999/xhtml',
      lang: 'zh-CN',
      style: 'font-size: 100px'
    },
    meta: [
      { charset: 'utf-8' },
      { 'http-equiv': 'cleartype', content: 'on' },
      { name: 'author', content: 'hi@yaavi.me' },
      // { name: 'MobileOptimized', content: '320' },
      { name: 'HandheldFriendly', content: 'True' },
      { name: 'apple-mobile-web-app-capable', content: 'yes' },
      { name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
      { name: 'apple-mobile-web-app-title', content: 'yaavi.me' },
      { name: 'apple-touch-icon', content: '/img/icon.png' },
      { name: 'msapplication-TileImage', content: '/img/icon.png' },
      { name: 'msapplication-TileColor', content: '#0088f5' },
      { name: 'format-detection', content: 'telephone=no' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1.0, user-scalable=no' },
      { hid: 'keywords', name: 'keywords', content: 'yaavi,孙亚威,javascript,nodejs,vue,前端开发,前端' },
      { hid: 'description', name: 'description', content: '要么庸俗 要么孤独' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      // { rel: 'stylesheet', type: 'text/css', href: '//at.alicdn.com/t/font_701523_ot0h9ran3jzia4i.css' }
    ],
    script: [
      {
        // async: 'async',
        // defer: 'defer',
        // type: 'text/javascript',
        // src: '/scripts/clmtrackr.js'
        // innerHTML: ``
      },
      {
        src: '//at.alicdn.com/t/font_701523_0g4cx2c1y4bu.js'
      }
    ],
    noscript: [
      { innerHTML: 'This website requires JavaScript.' }
    ]
  },
  cache: {
    max: 10000, // 缓存组件的最大数目
    maxAge: 15 * 60 * 1000 // 缓存时间，单位毫秒
  },
  router: {
    linkActiveClass: 'active',
    scrollBehavior: function (to, from, savedPosition) {
      return { x: 0, y: 0 }
    }
  },
  plugins: [
    { src: '~/plugins/axios' },
    { src: '~/plugins/global' },
    { src: '~/plugins/filters.js' },
    { src: '~/plugins/animation', ssr: false },
    { src: '~/plugins/particles', ssr: false },
    { src: '~/plugins/copy-right.js', ssr: false },
    { src: '~/plugins/swiper', ssr: false }
  ],
  css: [
    'swiper/dist/css/swiper.css',
    { src: '~/assets/css/init.styl', lang: 'stylus' }
  ],
  loading: {
    color: '#2da1fc',
    failedColor: '#ff4949',
    height: '1px'
  },
  modules: [
    '@nuxtjs/axios',
  ],
  axios: {
    // proxyHeaders: false
    baseURL: process.env.NODE_ENV == 'production' ? 'https://api.yaavi.me' : 'http://127.0.0.1:9003'
  }
}